const axios = require("axios");
const fs = require("fs");
let data = {
  page_params: {
    req_from: "web_vsite",
    page_id: "vsite_episode_list",
    page_type: "detail_operation",
    id_type: "1",
    page_size: "60",
    cid: "m441e3rjq9kwpsc",
    vid: "",
    lid: "",
    page_num: "",
    page_context:
      "lid=&cid=m441e3rjq9kwpsc&req_from=web_vsite&req_from_second_type=detail_operation&id_type=1&req_type=0&list_page_context=page_context%3Apg%3D2%3B&page_size=60&order=&ui_type=null&title_style=&filter_rule_id=&year=&chapter_name=&tab_type=&siteName=&detail_page_type=1&is_nocopyright=false&nav_tab_id=",
    detail_page_type: "1",
  },
  has_cache: 1,
};

axios({
  url: "https://pbaccess.video.qq.com/trpc.universal_backend_service.page_server_rpc.PageServer/GetPageData?video_appid=3000010&vplatform=2",
  headers: {
    "access-control-allow-credentials": true,
    cookie:
      "ts_uid=4579557820; pgv_pvid=7347777794; ts_last=v.qq.com/x/cover/mzc002007knmh3g/y00455moxwy.html; pgv_info=ssid=s7674787222; video_platform=2; video_omgid=7233d7a043530fc0; vversion_name=8.2.95; video_guid=7233d7a043530fc0; bucket_id=9231007; pgv_pvid=7347777794; tvfe_boss_uuid=f79a65fb1cfa3ec1; tab_experiment_data=expIds=#&statuses=1#1; ",
    origin: " https://v.qq.com",
    referer: "https://v.qq.com/",
  },
  method: "POST",
  data,
}).then((res) => {
  fs.writeFile("c.json", JSON.stringify(res.data.data), (err) => {});
  let resData = res.data.data || {};
  let data = {};
  try {
    let list =
      resData.module_list_datas[0].module_datas[0].item_data_lists
        .item_datas;
    data.list = list.map((item) => {
      {
        return {
          vid: item.item_params.vid,
          image_url: item.item_params.image_url,
          play_title: item.item_params.play_title,
          index: item.item_params.title,
        };
      }
    });
    data.page_context =
      resData.module_list_datas[0].module_datas[0].module_params.page_context;
    console.log(data);
  } catch (error) {
    console.log(error);
  }
});
